package caches

import (
	"time"
)

//type ItfCache interface {
//	Get(key string) (interface{}, error)
//	GetByExpire(key string, expired time.Duration) (interface{}, error)
//	GetSet(key string, value interface{}, expired time.Duration) (interface{}, error)
//	GetSetFunc(key string, f func() interface{}, expired time.Duration) (interface{}, error)
//	Exist(key string) (bool, error)
//	Delete(key string) error
//	GetActual(key string) interface{}
//
//	Set(string, interface{}) error
//	SetExpire(string, interface{}, time.Duration) error
//}

type ItfCache interface {
	Get(key string) (string, bool, error)                            //获取缓存值
	Set(key string, value string) error                              //设置缓存值
	SetExpire(key string, value string, expired time.Duration) error //设置缓存值且指定缓存时间
	TTL(key string) (time.Duration, error)                           //指定key的剩余过期时间

	Inc(k string, n int64) error  //对指定key的缓存值加
	Dec(k string, n int64) error  //对指定key的缓存值减
	Exist(k string) (bool, error) //判断缓存key是否存在
	Delete(key string) error      //删除指定缓存key
	GetSet(key string, value string, expired time.Duration) (string, error)
	GetSetFunc(key string, f func() string, expired time.Duration) (string, error)

	Keys() ([]string, error) //返回所有缓存key

	SetKeyPrefix(prefix string)
}

type ItemKey struct {
	Key    string        `json:"key"`    //key值
	Expire time.Duration `json:"expire"` //有效时间
}
